<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>已开发票金额</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<div class="project whitebg">
    <div  style="font-weight: bolder;font-size: large;">
        ${project.projectName}项目未开发票金额
    </div>
    <div class="right clearfix">
        <span  style="float: left;">${moneystr}</span>
        <input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel" onclick="exportExcelPro()">
        <input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewExcelPro()">
    </div>
    <div>
        <input type="hidden" id="projectId" value="${projectId}">
        <input type="hidden" id="projectName" value="${project.projectName}">
        <table id="tableList" style="height: 400px;" class="layui-hide" lay-filter="tableList"></table>
    </div>
    <div style="display: none">
        <table id="table">
        </table>
    </div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<script type="text/javascript">
    var layer;
    var form = layui.form;
    var table = null;
    var tableIns = null;
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    layui.use('element', function () {
        element = layui.element;
    });

    layui.use('table', function () {
        table = layui.table;
        element = element;
        //方法级渲染
        tableIns = table.render({
            defaultToolbar: ['filter', 'print', 'exports', {
                title: '提示' //标题
                , layEvent: 'LAYTABLE_TIPS' //事件名，用于 toolbar 事件中使用
                , icon: 'layui-icon-tips' //图标类名
            }],
            id: 'tableList',
            elem: '#tableList',
            title: '未开发票金额',
            url: '/search/buProjectInfo/selectNoKfPListZx?projectId=' + '${projectId}',
            cols: [[
                {
                    title: '序号', width: '20%',align: 'center', templet: function (res) {
                        return res.LAY_INDEX;
                    }
                },
                {field: 'fpMoney', title: '金额（元）', width: '80%',align: 'center'}
            ]],
            height: 'full-110',
            page: false,
            done: function (res, currentCount) {
                //***重点***：table渲染完成后渲染element进度条
                $(".layui-table-page select").css("width","80px");
                element.render()
            }
        });
       var  projectName="${project.projectName}";
        table.render({
            elem: '#table',
            id: 'exportTable',
            title: projectName+'_监理文档统计',
            cols: [[ //表头
                {
                    field: 'ordernum',
                    title: '序号',
                }, {
                    field: 'fileTypeName',
                    title: '文件类型',
                }, {
                    field: 'count',
                    title: '文件数量',
                }
            ]]
        });

    });

    //导出事件
    $('#export').on('click', function () {
        var json = {
            projectId: '${projectId}'
        }
        //使用ajax请求获取所有数据
        layerAjaxGet('/zx/projectManager/getTjData', json, '', function (d) {
            if (d.flag) {
                var str = "";
                var jsonarry = new Array();
                var k = 0;
                var count = 0;
                for (var y = 0; y < d.data.length; y++) {
                   var  json=d.data[y];
                    k=k+1;
                    json.ordernum=k;
                    count=count+json.count;
                    jsonarry.push(json);
                }
                jsonarry.push({"ordernum":"","fileTypeName":"合计：","count":count})
                table.exportFile('exportTable',jsonarry, 'xls');
            } else {
                layer.msg(d.msg, {icon: 2});
            }
        });
    });

    function exportExcelPro(){
        var projectId = $('#projectId').val();
        //获取全部数据:
        var url= '/search/buProjectInfo/exportExcelProZx?a_='+Math.random()+"&exCode=003&projectId="+projectId;
        location.href = url;
    }
    function viewExcelPro(){
        var projectId = $('#projectId').val();
        var  json={
            exCode:"003",
            projectId:projectId
        }
        layerAjaxGet('/search/buProjectInfo/viewExcelProZx',json,'',function (res) {
            if(res.flag){
                if(res.data){
                    var w = ($(window).width()*0.8);
                    var h = ($(window).height()*0.8);
                    POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + res.data, 'width=1200px;height=800px;', '{}')
                }
            }
        })


    }

</script>

</body>

</html>
